<template>
  <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
  <div id="chartLine" class="line-wrap"></div>
</template>

<script>
import * as echarts from 'echarts';

require('echarts/theme/shine');//引入主题

export default {
  data() {
    return {
      chartLine: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.drawLineChart();
    })
  },
  methods: {
    drawLineChart() {
      this.chartLine = echarts.init(this.$el, 'shine');// 基于准备好的dom，初始化echarts实例
      let option = {
        tooltip: {
          // backgroundColor: '#fff',
          borderColor: 'rgba(88, 82, 82, 1)',
          textStyle: {
            color: '#fff'
          },
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#fff'
            }
          },
          trigger: 'axis'
        },
        legend: {
          data: ['登陆量', '接口请求量', 'Ip登陆量'],
          textStyle: {
            fontSize: 20, // 字体大小
            padding: 15,
          }
        },
        calculable: true,
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            nameTextStyle: {
              fontSize: 15
            },
            axisTick: {
              show: false
            },
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisTick: {
              show: false
            },
            name: '（人）'
          }
        ],
        series: [
          {
            name: '登陆量',
            type: 'line',
            stack: '总量',
            // data: [120, 132, 101, 134, 90, 230, 210],
            data: [2, 3, 1, 3, 3, 3, 2],
            itemStyle: {
              normal: {
                color: '#FF005A',
                lineStyle: {
                  color: '#FF005A',
                  width: 2
                }
              }
            },
            smooth: true,
          },
          {
            name: '接口请求量',
            type: 'line',
            stack: '总量',
            data: [5, 4, 3, 3, 2, 3, 3],
            itemStyle: {
              normal: {
                color: '#3888fa',
                lineStyle: {
                  color: '#3888fa',
                  width: 2
                },
                areaStyle: {
                  color: '#f3f8ff'
                }
              }
            },
          },
          {
            name: 'Ip登陆量',
            type: 'line',
            stack: '总量',
            data: [1, 3, 2, 5, 1, 3, 4],
            itemStyle: {
              normal: {
                color: '#ff9999',
                lineStyle: {
                  color: '#ff9999',
                  width: 2
                },
                areaStyle: {
                  color: '#f3f8ff'
                }
              }
            },
          },
        ]
      };
      // 使用刚指定的配置项和数据显示图表
      this.chartLine.setOption(option);
    }
  }
}
</script>

<style  scope>
.line-wrap {
  width: 100%;
  height: 400px;

}
</style>
